<?php
namespace Info\Controller;
use  Info\Controller\CommonController;
use Common\Model\InfoContentModel;
class ListController extends CommonController {
    
    public function index(){


        if(C('URL_MODEL') == 0){
            $pid = I('pid',0,'int');
            $cid = I('cid',0,'int');
            $area = I("area",0,'int');
            $m1 = I('m1',0,'int');
            $m2 = I('m2',0,'int');
        }else{
            $url =  'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
            $parameter = explode('-',pathinfo($url)['filename']);
            $pid = isset($parameter[0]) && (int)$parameter[0] >= 0 ? (int)$parameter[0] : 0;
            $pid = !$pid ? I('pid',0,'int') : $pid ;
            $cid = isset($parameter[1]) && (int)$parameter[1] >= 0 ? (int)$parameter[1] : 0;
            $area = isset($parameter[2]) && (int)$parameter[2] >= 0 ? (int)$parameter[2] : 0;
            $m1 = isset($parameter[3]) && (int)$parameter[3] > 0 ? (int)$parameter[3] : 0;
            $m2 = isset($parameter[4]) && (int)$parameter[4] > 0 ? (int)$parameter[4] : 0;
        }
        $info = new InfoContentModel();
        $infoListdata = $info->getInfoData($pid,$cid,$area,$m1,$m2);
        $category = $this->getListCategory($pid);

        $areaName = isset(C('city_area')[$area]) ? C('city_area')[$area] : "十堰";

        $AllCategory = $this->getAllCategory();
        $categoryPid = array_column($category,'category','pid');
        $categoryCid = array_column($category,'category','id');
        $url = UU("Info/list/index",array('pid'=>$pid,'cid'=>$cid,'area'=>$area,'m1'=>$m1,'m2'=>$m2));

        $pageShow = PageShow($infoListdata['count'],$url);

        $this->assign('data',$infoListdata['data'])
            ->assign('cid',$cid)
            ->assign('pid',$pid)
            ->assign('area',$area)
            ->assign('m1',$m1)
            ->assign('m2',$m2)
            ->assign('areaName',$areaName)
            ->assign('categoryPid',$categoryPid)
            ->assign('categoryCid',$categoryCid)
            ->assign('allCategory',$AllCategory)
            ->assign('displaytype',$this->displaytype)
            ->assign('pageShow',$pageShow)
            ->assign("category",$category);

        $this->display(':list');
    }

}